package congen.utils;

import ConnectorGenerator.DRD.Component;
import ConnectorGenerator.DRD.Interface;
import ConnectorGenerator.DRD.util.DRDSwitch;


public class DrdToString extends DRDSwitch<String> {

	@Override
	public String caseComponent(Component object) {
		String text = String.format("component %s:\n", object.getName());
		if (object.getInterfaces().size() > 0) {
			text += "\tinterfaces: ";
			boolean first = true;
			for (Interface i: object.getInterfaces()) {
				if (!first)
					text += ", ";
				text += caseInterface(i);			
				first = false;
			}
		}
		return text;
	}
	
	@Override
	public String caseInterface(Interface object) {
		String text = String.format("% %", object.getSignature(), object.getName());
		return text;
	}	

}
